package com.bilibili.demo;

import java.util.Scanner;

public class Smart {
    private static Smart kongzhi = new Smart();
    private Smart(){}
    public static Smart getKongzhi(){
        return kongzhi ;
    }

    public void smart(JD[] jds){

        while (true){

            System.out.println("列表:");
            for (int i = 0; i < jds.length; i++) {
                JD jd = new JD();
                jd = jds[i];
                System.out.println(i + 1 + "." + jd.getName() + "\n" + (jd.isSatus() ? "打开！" : "关闭！"));
            }
            System.out.println("请输入控制：");
            Scanner num = new Scanner(System.in);
            int n = num.nextInt();
            switch (n) {
                case 1:
                    select(jds[0]);
                    break;
                case 2:
                    select(jds[1]);
                    break;
                case 3:
                    select(jds[2]);
                    break;
                case 4:
                    select(jds[3]);
                    break;
                case 0:
                    System.out.println("已经退出！");
                    return;
            }

        }

    }
    public void select(JD jd){
        jd.press();
        System.out.println(jd.getName()+"已经"+ (jd.isSatus()?"打开！":"关闭！"));
    }
}
